#!/bin/bash


#function usage
usage()
{
  echo "usage: mkp [project_name]"
  exit 1
}

TEMPLATE_DIR=${OOBC_HOME}/shared/template

if [ -n "$1" ]; then
  if [ ! -w "$WORKSPACE_DIR" ]; then
    echo "Project creating failed:WORKSPACE $WORKSPACE_DIR is not writable."
    exit 1
  fi	
  PROJECT_HOME=${WORKSPACE_DIR}/$1
else
  echo "Project creating failed:project name missing."
  usage
fi

if [ -d "$PROJECT_HOME" ]; then
  echo "Project creating failed:$PROJECT_HOME exists."
  exit 1	
fi

mkdir $PROJECT_HOME
mkdir ${PROJECT_HOME}/src
mkdir ${PROJECT_HOME}/include
mkdir ${PROJECT_HOME}/tests
cp ${TEMPLATE_DIR}/ProjectMakeFileTemplate ${PROJECT_HOME}/tests/makefile

echo "Project created under ${PROJECT_HOME}."	
